﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AutoTestEntry.Utility
{
    class Installer
    {
        private String type;

        #region Install Finished Event
        public class InstallFinishedEventArgs : EventArgs
        {
            public readonly String Type;
            public InstallFinishedEventArgs(String type)
            {
                Type = type;
            }
        }
        public delegate void InstallFinishedEventHandler(Object sender, InstallFinishedEventArgs e);
        public event InstallFinishedEventHandler InstallFinishedEvent;
        #endregion

		#region Install
        public void Install(String path, String type)
        {
            this.type = type;
            Process process = new Process();
            process.StartInfo.FileName = path;
            process.StartInfo.Arguments = "/quiet /qr";
            process.EnableRaisingEvents = true;
            process.Exited += ProcessExitedHandler;
            process.Start();
        }

        private void ProcessExitedHandler(Object sender, EventArgs e)
        {
            InstallFinishedEvent(this, new InstallFinishedEventArgs(type));
		}
		#endregion
	}
}
